﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="InputKPIAssignDetailPage.aspx.cs" Inherits="FBKPI.Pages.InputKPIAssignDetailPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            mainmenu("#nav ul", "#nav li");
            mainmenu("#menu_wrap ul", "#menu_wrap li");

            $("#divBrowseEmployee").hide();
            $("#divBrowseEmployee").dialog({ autoOpen: false, width: 900, height: 500, modal: true, resizable: false });

            $("#btn_back").click(function () {
                document.location = "../Pages/KPIAssignDetailPage.aspx";//?User=" + $("#txt_user").val();
                return false;
            });

            

            $("#btn_BrowseEmployee").click(function () {
                $("#divBrowseEmployee").dialog("option", "title", '<span class="header-text">Select Employee</span>');
                $("#divBrowseEmployee").dialog("open");
                $('#employee').dataTable({
                    "oLanguage": {
                        "sZeroRecords": "No records to display",
                        "sSearch": "Search"
                    },
                    "bSort": false,
                    "bPaginate": true,
                    "bAutoWidth": true,
                    "bProcessing": true,
                    "bServerSide": true,
                    "bDestroy": true,
                    "bJQueryUI": true,
                    "sPaginationType": "full_numbers",
                    "bDeferRender": true,
                    "fnServerData": function (sSource, aoData, fnCallback) {
                        $.ajax({
                            "dataType": 'json',
                            "type": "GET",
                            "url": "../Serializer/EmployeeHierarchySerializer.ashx?CurrUser=" + $("#txt_user").val(),
                            "data": aoData,
                            "success": fnCallback
                        });
                    },
                    "aoColumns": [
                        { "mData": "No", "sWidth": "3%" },
                        { "mData": "FirstName", "sWidth": "20%" },
                        { "mData": "LastName", "sWidth": "20%" },
                        { "mData": "Department" },
                        { "mData": "Section" },
                        { "mData": "SubSection" },
                        { "mData": "JobPosition", "sWidth": "10%" },
                        { "mData": "ID", "sWidth": "5%" }
                    ],
                    "aoColumnDefs":
                    [
                        { "fnRender":
                            function (oObj) {
                                return "<a href=\"#\" onclick=\"PickEmployee('" + oObj.aData["ID"] + "','" + oObj.aData["FirstName"] + " " + oObj.aData["LastName"] + "')\"><img src='../images/ok.png' /></a>";
                            },
                            "aTargets": [7]
                        },
                        {
                            "bVisible": false,
                            "aTargets": [2,4, 5]
                        },
                        { "sClass": "center", "aTargets": [0, 7] }
                    ]
                });

                //mark selected row
                $('body').on("click", '#employee tbody tr', function () {
                    $('#employee tbody tr').removeClass("row_selected");
                    $(this).addClass("row_selected");
                });
                $(".dataTables_filter input").focus();
                return false;
            });

            PickEmployee = function (EmployeeID, EmployeeName) {
                $("#MainContent_txt_employee").val(EmployeeName);
                $("#MainContent_txt_employeeid").val(EmployeeID);
                $("#divBrowseEmployee").dialog("close");
            }


            $("#<%=btn_save.ClientID%>").click(function () {
                var param = "?";
                var KpiID = $("#<%=hfKpiID.ClientID%>").val();
                var EmployeeID = $("#<%=txt_employeeid.ClientID%>").val();
                var Weight = $("#<%=txt_weight.ClientID%>").val();
                var WeightAssign = $("#<%=txtWeightAssign.ClientID%>").val();
                var Mandatory = $("#<%=ddlMandatory.ClientID%> option:selected").val();

                param = param + "action=InputAssignKPI";
                param = param + "&KpiID=" + KpiID;
                param = param + "&EmployeeID=" + EmployeeID;
                param = param + "&Weight=" + Weight;
                param = param + "&Mandatory=" + Mandatory;
                param = param + "&WeightAssign=" + WeightAssign;
                param = param + "&CurrUser=" + $("#txt_user").val();
                //ProcessRequest("KPIAssignDetailHandler.ashx" + param, "#divdetail", "#DepartmentTable");

                // document.location = "../Pages/KPIAssignDetailPage.aspx";//?User=" + $("#txt_user").val();

                $.ajax({ url: '../ProcessRequest/' + "KPIAssignDetailHandler.ashx"+param, type: "POST",
                    success: function (response) {
                        //alert(response);
                        $.msgBox(response, null, { title: "Pesan" });
                        if (response.indexOf('Success') > 0) {

                            document.location = "../Pages/KPIAssignDetailPage.aspx"; //?User=" + $("#txt_user").val();
                        }
                        else
                            return false;
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        //alert(xhr.responseText);
                        $.msgBox(xhr.responseText, null, { title: "Pesan Error" });
                    }
                });

               
                return false;//
            });

        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <form id="formInputKPIAssignDetail" action="KPIAssignDetailPage.aspx">
    <div>
        <div class="customPageTitle">
            KPI Information</div>
        <br />
        <div class="customPageContent">
            <table width="100%">
                <tr>
                    <td width="50%">
                        <table>
                            <tr>
                                <td width="140px">
                                    Description
                                </td>
                                <td class="Separator">
                                    :
                                </td>
                                <td>
                                    <asp:TextBox TextMode="MultiLine" Width="400" ID="txt_kpidescription" runat="server" ReadOnly="true" class="longText"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="140px">
                                    Group
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_kpigroup" Width="400" runat="server" ReadOnly="true" class="longText"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="140px">
                                    Category
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_kpicategory" Width="400" runat="server" ReadOnly="true" class="longText"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="140px">
                                    Type
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_kpitype" Width="400" runat="server" ReadOnly="true" class="longText"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="140px">
                                    Sub Type
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_kpisubtype" Width="400" runat="server" ReadOnly="true" class="longText"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="140px">
                                    Year
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_kpiyear" runat="server" ReadOnly="true"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td width="140px">
                                    Periode
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_kpiperiode" runat="server" ReadOnly="true"></asp:TextBox>
                                </td>
                            </tr>
                           
                           <%-- <tr>
                                <td style="vertical-align: top">
                                    Detail Information
                                </td>
                                <td style="vertical-align: top">
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_detailinformation" runat="server" ReadOnly="true" TextMode="MultiLine"
                                        CssClass="MultilineTextbox"></asp:TextBox>
                                </td>
                            </tr>--%>
                        </table>
                    </td>
                    <td width="50%">
                        <table>
                           <%-- <tr>
                                <td width="140px">
                                    Target Description
                                </td>
                                <td class="Separator">
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_kpitargetdescription" runat="server" ReadOnly="true" class="longText"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Manual Calculation
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_kpimanualcalculation" runat="server" ReadOnly="true"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Calculation Type
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_calculationtype" runat="server" ReadOnly="true"></asp:TextBox>
                                </td>
                            </tr>--%>

                             <tr>
                                <td style="padding-left:50px;">
                                    Polarization
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_polarization" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td style="padding-left:50px;">
                                    Unit of Measure
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_kpiuom" runat="server" ReadOnly="true" class="longText"></asp:TextBox><input
                                        type="hidden" runat="server" id="txt_uomformat" />
                                </td>
                            </tr>
                            <tr>
                                <td style="padding-left:50px;">
                                    UoM Max
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_kpiuommax" runat="server" ReadOnly="true" class="longText"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td style="padding-left:50px;">
                                    UoM Min
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_kpiuommin" runat="server" ReadOnly="true" class="longText"></asp:TextBox>
                                </td>
                            </tr>

                            <tr>
                                <td style="padding-left:50px;">
                                    Weight
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_weight" runat="server" ReadOnly="true"></asp:TextBox>
                                </td>
                            </tr>
                           <%-- <tr>
                                <td>
                                    KPI Parent
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_kpiparent" runat="server" ReadOnly="true" class="longText"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    KPI Replacement
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_kpireplacement" runat="server" ReadOnly="true" class="longText"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Replacement Date
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_replacementdate" runat="server" ReadOnly="true"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Replacement Desc.
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_replacementdescription" runat="server" ReadOnly="true" class="longText"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Weight Enable Flag
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:CheckBox ID="chk_weightenableflag" runat="server" Enabled="false" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    UoM Enable Flag
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:CheckBox ID="chk_uomenableflag" runat="server" Enabled="false" />
                                </td>
                            </tr>--%>
                            <tr>
                                <td style="padding-left:50px;">
                                    is Active
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:CheckBox ID="chk_active" runat="server" Enabled="false" />
                                </td>
                            </tr>
                           <%-- <tr>
                                <td style="vertical-align: top">
                                    Strategic Objective
                                </td>
                                <td style="vertical-align: top">
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_strategicobjective" runat="server" ReadOnly="true" TextMode="MultiLine"
                                        CssClass="MultilineTextbox"></asp:TextBox>
                                </td>
                            </tr>--%>
                        </table>
                    </td>
                </tr>
            </table>
        </div>
        <br />
        <div class="customPageTitle">
            Assign KPI</div>
       <br />
        <div class="customPageContent">
            <table width="100%">
                <tr>
                    <td width="100%">
                        <table>
                            <tr runat="server" visible="false">
                                <td width="140px">
                                    ID
                                </td>
                                <td class="Separator">
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_assignid" runat="server" ReadOnly="true" Text="0"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td  width="140px">
                                    Employee
                                </td>
                                <td class="Separator">
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txt_employee" Width="300" runat="server" ReadOnly="true" class="mandatory"></asp:TextBox>
                                    <button id="btn_BrowseEmployee" class="ui-button ui-state-default">
                                        <span class="ui-button ui-icon ui-icon-newwin"></span>
                                    </button>
                                    <input type="hidden" runat="server" id="txt_employeeid" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Mandatory
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddlMandatory" runat="server">
                                        <asp:ListItem Text="Yes" Value="1"></asp:ListItem>
                                        <asp:ListItem Text="No" Value="0"></asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Lock Weight
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <%--<asp:CheckBox Enabled="false" ID="chkLockWeight" runat="server" />--%>
                                    <asp:Label ID="lblLock" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Method Weight
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txtScoreWeight" ReadOnly="true"  runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                     Weight Assign
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txtWeightAssign" runat="server" ReadOnly="true"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    is Active
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:CheckBox ID="chk_assingisactive" Checked="true" runat="server" />
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </div>
        <div id="divBrowseEmployee" class="ui-widget-content padding5px ui-corner-all">
            <table cellpadding="0" cellspacing="0" border="0" class="display" id="employee">
                <thead>
                    <tr>
                        <th>
                            No
                        </th>
                        <th>
                            Name
                        </th>
                        <th>
                            Last Name
                        </th>
                        <th>
                            Department
                        </th>
                        <th>
                            Section
                        </th>
                        <th>
                            Sub Section
                        </th>
                        <th>
                            Job Position
                        </th>
                        <th>
                        </th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
        <br />
        <button id="btn_save" class="ui-button ui-corner-all ui-button ui-state-default ui-button-text-icon-primary"
            runat="server" name="btnSave">
            <span class="ui-button-icon-primary ui-icon ui-icon-check"></span>
            <label class="ui-button-text">
                Save</label>
        </button>
        <button id="btn_back" class="ui-button ui-corner-all ui-button ui-state-default ui-button-text-icon-primary">
            <span class="ui-button-icon-primary ui-icon ui-icon-arrowthick-1-w"></span>
            <label class="ui-button-text">
                Back</label>
        </button>
    </div>
    <asp:HiddenField ID="hfKpiID" runat="server" Value="" />
    </form>
</asp:Content>
